{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "kxu1Gfhx1pHg"
   },
   "source": [
    "<a href=\"https://colab.research.google.com/github/jeffheaton/app_generative_ai/blob/main/t81_559_class_12_5_create.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ZbNbAV281pHh"
   },
   "source": [
    "# T81-559: Applications of Generative Artificial Intelligence\n",
    "**Module 12: Prompt Engineering**\n",
    "* Instructor: [Jeff Heaton](https://sites.wustl.edu/jeffheaton/), McKelvey School of Engineering, [Washington University in St. Louis](https://engineering.wustl.edu/Programs/Pages/default.aspx)\n",
    "* For more information visit the [class website](https://sites.wustl.edu/jeffheaton/t81-558/)."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {
    "id": "HwnvSYEQ1pHi"
   },
   "source": [
    "# Module 12 Material\n",
    "\n",
    "Module 12: Prompt Engineering\n",
    "\n",
    "* Part 12.1: Intro to Prompt Engineering [[Video]](https://www.youtube.com/watch?v=p8q2kFhyX3M&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_1_prompt_engineering)\n",
    "* Part 12.2: Few Shot and Chain of Thought [[Video]](https://www.youtube.com/watch?v=Bj-zOiqpp6g&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_2_fewshot_cot.ipynb)\n",
    "* Part 12.3: Persona and Role Patterns [[Video]](https://www.youtube.com/watch?v=uD9z3LFw7nA&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_3_persona.ipynb)\n",
    "* Part 12.4: Question, Refinement and Verification Patterns [[Video]](https://www.youtube.com/watch?v=UF0gN79hg4g&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_4_refinement_eval.ipynb)\n",
    "* **Part 12.5: Content Creation and Structured Prompt Patterns** [[Video]](https://www.youtube.com/watch?v=PPNnTDfKjPE&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_5_create.ipynb)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "v2MPPX0c1pHi"
   },
   "source": [
    "# Part 12.5: Content Creation and Structured Prompt Patterns\n",
    "\n",
    "In this part, we'll cover how to generate content and structure responses using specific formats or instructions to tailor outputs within the life insurance context. By mastering these patterns, you can guide Generative AI to produce content that meets your exact needs—whether it's drafting policy summaries, creating client communications, or extracting specific data.\n",
    "\n",
    "### Template Pattern\n",
    "The Template Pattern involves providing a predefined structure or format that the AI should follow when generating its response. This is particularly useful when you need outputs in a specific layout or style.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Using the following template, create a life insurance policy summary:\n",
    "\n",
    "Policy Name:\n",
    "Policy Type:\n",
    "Coverage Amount:\n",
    "Premium Details:\n",
    "Key Benefits:\n",
    "Exclusions:\n",
    "Additional Riders:\n",
    "```\n",
    "\n",
    "### Meta Language Pattern\n",
    "The Meta Language Pattern uses specific placeholders or instructions within the prompt to guide the AI's response, allowing for dynamic content generation.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Draft a personalized email to [Client Name], informing them about the benefits of upgrading their current life insurance policy to include [New Feature/Rider].\n",
    "```\n",
    "\n",
    "### Recipe Pattern\n",
    "The Recipe Pattern provides step-by-step instructions or procedures, guiding the AI to produce content that follows a logical sequence.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Provide a step-by-step guide on how to file a life insurance claim, including all necessary documentation and timelines.\n",
    "```\n",
    "\n",
    "### Alternative Approaches Pattern\n",
    "The Alternative Approaches Pattern asks the AI to present multiple solutions or perspectives on a given topic, allowing for a broader understanding.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Describe three different strategies for a young family to maximize their life insurance coverage while staying within a limited budget.\n",
    "```\n",
    "\n",
    "### Outline Expansion Pattern\n",
    "The Outline Expansion Pattern involves giving the AI an outline or set of bullet points and asking it to expand them into a detailed narrative.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Expand the following points into a comprehensive article about term life insurance:\n",
    "\n",
    "Definition of term life insurance\n",
    "Affordability and simplicity\n",
    "Ideal candidates for term life policies\n",
    "Comparison with whole life insurance\n",
    "How to choose the right term length\n",
    "```\n",
    "\n",
    "### Menu Actions Pattern\n",
    "The Menu Actions Pattern directs the AI to provide options or action items in response to a scenario, much like choosing from a menu.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "List the available policy options for a 35-year-old non-smoker seeking life insurance coverage of $500,000, including term lengths and premium estimates.\n",
    "```\n",
    "\n",
    "### Tail Generation Pattern\n",
    "The Tail Generation Pattern instructs the AI to complete a partially written piece of content, ensuring consistency and continuity.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Finish the following letter to a client regarding their policy renewal:\n",
    "\n",
    "'Dear [Client Name],\n",
    "\n",
    "We wanted to remind you that your life insurance policy is up for renewal on [Date]. Continuing your coverage is important because...'\n",
    "```\n",
    "\n",
    "### Completion Prompts\n",
    "Completion Prompts provide the beginning of a sentence or paragraph and ask the AI to finish it, often used to inspire creativity or generate ideas.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Life insurance plays a vital role in financial planning by...\n",
    "```\n",
    "\n",
    "### Content Generation Prompts\n",
    "Content Generation Prompts ask the AI to create original content on a specified topic, useful for drafting articles, reports, or marketing materials.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Write a blog post titled 'The Top 5 Myths About Life Insurance Debunked' aimed at educating potential clients.\n",
    "```\n",
    "\n",
    "### Classification Prompts\n",
    "Classification Prompts involve organizing information into categories or groups based on specific criteria.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Classify the following clients into appropriate life insurance policy types:\n",
    "\n",
    "Client A: 28 years old, newly married, first child on the way\n",
    "Client B: 45 years old, high-income earner, interested in investment opportunities\n",
    "Client C: 60 years old, planning for estate transfer to grandchildren\n",
    "```\n",
    "\n",
    "### Translation Prompts\n",
    "Translation Prompts ask the AI to translate content from one language to another or adapt it to a different style or format.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Translate the following life insurance FAQ into simplified Chinese for our international clients:\n",
    "\n",
    "'What is the difference between term and whole life insurance?'\n",
    "```\n",
    "\n",
    "### Data Extraction Prompts\n",
    "The Data Extraction Prompts instruct the AI to extract specific pieces of information from a larger text.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "From the following policy document, extract the policyholder's name, policy number, coverage amount, and beneficiary details.\n",
    "```\n",
    "\n",
    "### Style-Based Prompts\n",
    "Style-Based Prompts guide the AI to produce content in a particular tone, style, or voice, ensuring the output aligns with brand guidelines or audience preferences.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Write an informative article about the benefits of life insurance for small business owners in a professional and persuasive tone.\n",
    "```\n",
    "\n",
    "### Interactive/Iterative Prompts\n",
    "Interactive/Iterative Prompts involve an ongoing exchange with the AI, refining and building upon previous responses to reach a desired outcome.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Based on the following client profile, recommend a suitable life insurance policy. After your recommendation, I will provide feedback for you to adjust the proposal accordingly.\n",
    "\n",
    "Client Profile:\n",
    "\n",
    "Age: 40\n",
    "Occupation: Teacher\n",
    "Family: Married with two children\n",
    "Financial Goals: Affordable premiums, college savings for children\n",
    "```\n",
    "\n",
    "By applying these patterns within the life insurance context, you can effectively structure AI-generated content to meet specific requirements, improve communication with clients, and enhance the overall quality of information. Practice using these techniques to become proficient in guiding Generative AI to produce tailored and high-quality outputs in your field."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
